function saveJion(formId,sign)
{
	
	if(isNull("选手姓名","joiner","text",255)){
		return;
	}
	else
	{
		var joiner = $("#joiner").val();
		// var re = /^([0-9|a-z|A-Z|\u4e00-\u9fa5])+(,[0-9|a-z|A-Z|\u4e00-\u9fa5]+)*$/; 
		if(!REG_NAME_COMMA.test(joiner)){
			alert("输入的选手姓名错误，选手姓名间以逗号隔开，不能以逗号结尾，不能输入的特殊字符");
			return false;
		}
	}
	
	if(isNull("组别","groupType","select")){return;}
	
	if(isNull("paint"==sign?'展示类型':'展示大类',"bigCategory","select")){return;}
	
	
	var bigCategory = $("#bigCategory").val();
	if("other" != bigCategory && sign != "paint")
	{
		if(isNull("展示小类","smallCategory","select")){
			return;
		}
	}
	
	if(isNull("展示方式","joinType","select")){return;}
	
	// 判断选择的展示方式和人数是否一致
	var joinType = $("#joinType").val();
	var joiner = $("#joiner").val();
	var joinNum = joiner.split(",").length;
	if("3" == joinType)
	{
		if(joinNum < joinType)
		{
			alert("选择的展示类型和输入的选手姓名不匹配，请重新输入");
			return false;
		}
	}
	else
	{
		if(joinNum != joinType)
		{
			alert("选择的展示类型和输入的选手姓名不匹配，请重新输入");
			return false;
		}
	}
	
	
	if(isNull("推选学校","school","text",64)){return;}
	
	if(isNull("家长姓名","register","text",32)){return;}
	// else if(isNull("协议折扣","signDiscount","number",2)){return;}
	// else if(isNull("景区售票用户","scenicTicket","select")){return;}
	if(isNull("家长电话","mobile","text",15)){
		return;
	}
	else
	{
		var mobile = $("#mobile").val();
		// var re = /^([0-9|a-z|A-Z|\u4e00-\u9fa5])+(,[0-9|a-z|A-Z|\u4e00-\u9fa5]+)*$/; 
		if(!REG_MOBILE_PATTERN.test(mobile)){
			alert("输入的家长电话格式错误，请重新输入");
			return false;
		}
	}
	
	if(isNull("验证码","validateCode","text")){return;}
	
	createOrder(formId);
}

function count(id,oneMoney,multiMoney,joinType)
{
	var val = $("#"+id).val();
	// var re = /^([0-9|a-z|A-Z|\u4e00-\u9fa5]+)(,[0-9|a-z|A-Z|\u4e00-\u9fa5]+)*$/;
	if(!val)
	{
		$("#joinNum").html("0");
		$("#joinMoney").html("0.00");
	}else 
	// 若含有中文逗号，则替换成英文逗号
	if(val.indexOf("，") > -1){
		val = val.replace(/，/g,",");
		$("#"+id).val(val);
	}else
		
	if(!REG_NAME_COMMA.test(val)){
		return false;
	}else
	{
		// 若含有中文逗号，则替换成英文逗号
		if(val.indexOf("，") > -1){
			
			val = val.replace(/，/g,",");
			$("#"+id).val(val);
		}
		
		var joinNum = val.split(",").length;
		
		$("#joinNum").html(joinNum);
		
		var joinType = $("#" + joinType).val();
		// 没有选择joinType时，不做处理
		if(!joinType)
		{
			return;
		}
		
		var singleMoney = oneMoney;
		// 计算金额
		if("3" == joinType)
		{
			singleMoney = multiMoney;
		}
		var totalMoney = joinNum * singleMoney;
		totalMoney = totalMoney.toFixed(2);
		$("#joinMoney").html(totalMoney);
		
		$("#confirmDiv").show();
	}
}

function countPaste(id,oneMoney,multiMoney,joinType)
{
	setTimeout(function(){count(id,oneMoney,multiMoney,joinType);},0); 
}

function createOrder(formId)
{
	$("#subButton").val("正在提交...");
	$("#subButton").attr("disabled",true);
	//提交后台
	var formData = new FormData(document.getElementById(formId));//表单id
	$.ajax({
		url: ctx+"/ems/createOrder",
		type:"post",
		async:false,
		data:formData,
		cache: false,  
        processData: false,  
        contentType: false,
		success:function(data){
			var orderId = data.data;
			if(data.success){
				$("#orderId").val(orderId);
				// 报名表单提交
				$("#" + formId).submit();
				
			}else{
				
				if("验证码输入错误，请重新输入" == orderId)
				{
					$("#" + formId).submit();
				}
				else
				{
					alert("生成订单失败：(" + orderId + ")，" + '请联系管理员');
				}
				$("#subButton").val("确认信息");
				$("#subButton").attr("disabled",false);
            }
		},
		error:function(xhr,errorText,errorType) { //xhr:XMLHttpRequest对象  errorText:错误信息  erroType：（可选）捕获的异常对象  
	        alert("系统错误：(" + errorType + ")，" +errorText + '请联系管理员'); 
	        $("#subButton").val("确认信息");
			$("#subButton").attr("disabled",false);
	    }  
	});
}

function checkSearch(formId)
{
	var name = $("#name").val();
	// var mobile = $("#mobile").val();
	if(!name)
	{
		alert("请输入选手姓名");
		return false;
	}
	/*if(!mobile)
	{
		alert("请输入家长电话");
		return false;
	}*/
	return true;
}




